package studentwjchoi;
import junit.framework.TestCase;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class CurseSessionTests extends TestCase {
	
	private CourseSession session;
	private Date startDate;
	
	public void setUp(){
		startDate = new Date();
		startDate = createDate(2003, 1, 6);
		session = new CourseSession("ENGL", "101",startDate);
	}

	public void testCreate(){
		assertEquals("ENGL", session.getCourseName());
		assertEquals("101", session.getCourseNo());
		assertEquals(startDate, session.getStartDate());
		
		Student student1 = new Student("John");
		session.enroll(student1);
		assertEquals(1, session.getNumberofStudent());

		java.util.ArrayList<Student> allStudents = session.getAllStudents();
		assertEquals(1, allStudents.size());
		assertEquals(student1, allStudents.get(0));
		
		Student student2 = new Student("Tom");
		session.enroll(student2);
		assertEquals(2, session.getNumberofStudent());
		assertEquals(2, allStudents.size());
		assertEquals(student1, allStudents.get(0));
		assertEquals(student2, allStudents.get(1));
	}
	
	public void testCourseDates(){
		Date sixteenweeksOut = new Date();
		sixteenweeksOut = createDate(2003, 4, 26); 
		assertEquals(sixteenweeksOut, session.getEndDate());
	}
	
	Date createDate(int year, int month, int day){
		GregorianCalendar calendar = new GregorianCalendar();
		calendar.clear();
		calendar.set(Calendar.YEAR, year);
		calendar.set(Calendar.MONTH, month);
		calendar.set(Calendar.DAY_OF_MONTH, day);
		return calendar.getTime();
		
	}
	
}
